package ru.niir.goodfil.db.handlers.hack;

import org.hibernate.*;
import org.hibernate.transform.ResultTransformer;
import org.hibernate.type.Type;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

import static ru.niir.goodfil.utils.Utils._assertNotNull;

public class MyQuery implements Query {
    private final Query query;

    public MyQuery(Query query) {
        _assertNotNull(query);
        this.query = query;
    }

    public String getQueryString() {
        return query.getQueryString();
    }

    public Query setFlushMode(FlushMode flushMode) {
        return new MyQuery(query.setFlushMode(flushMode));
    }

    public Query setCacheMode(CacheMode cacheMode) {
        return new MyQuery(query.setCacheMode(cacheMode));
    }

    public Query setCacheable(boolean b) {
        return new MyQuery(query.setCacheable(b));
    }

    public Query setCacheRegion(String s) {
        return new MyQuery(query.setCacheRegion(s));
    }

    public Query setComment(String s) {
        return new MyQuery(query.setComment(s));
    }

    public Query setFirstResult(int i) {
        return new MyQuery(query.setFirstResult(i));
    }

    public Query setMaxResults(int i) {
        return new MyQuery(query.setMaxResults(i));
    }

    public Query setTimeout(int i) {
        return new MyQuery(query.setTimeout(i));
    }

    public Query setFetchSize(int i) {
        return new MyQuery(query.setFetchSize(i));
    }

    public Type[] getReturnTypes()
            throws HibernateException {
        return query.getReturnTypes();
    }

    public String[] getReturnAliases()
            throws HibernateException {
        return query.getReturnAliases();
    }

    public Query setReadOnly(boolean b) {
        return new MyQuery(query.setReadOnly(b));
    }

    public Query setResultTransformer(ResultTransformer resultTransformer) {
        return new MyQuery(query.setResultTransformer(resultTransformer));
    }

    public String[] getNamedParameters()
            throws HibernateException {
        return query.getNamedParameters();
    }

    public Query setParameter(int i, Object o, Type type) {
        return new MyQuery(query.setParameter(i, o, type));
    }

    public Query setParameter(String s, Object o, Type type) {
        return new MyQuery(query.setParameter(s, o, type));
    }

    public Query setParameter(int i, Object o)
            throws HibernateException {
        return new MyQuery(query.setParameter(i, o));
    }

    public Query setParameter(String s, Object o)
            throws HibernateException {
        return new MyQuery(query.setParameter(s, o));
    }

    public Query setString(int i, String s) {
        return new MyQuery(query.setString(i, s));
    }

    public Query setCharacter(int i, char c) {
        return new MyQuery(query.setCharacter(i, c));
    }

    public Query setBoolean(int i, boolean b) {
        return new MyQuery(query.setBoolean(i, b));
    }

    public Query setByte(int i, byte b) {
        return new MyQuery(query.setByte(i, b));
    }

    public Query setShort(int i, short s) {
        return new MyQuery(query.setShort(i, s));
    }

    public Query setInteger(int i, int i1) {
        return new MyQuery(query.setInteger(i, i1));
    }

    public Query setLong(int i, long l) {
        return new MyQuery(query.setLong(i, l));
    }

    public Query setFloat(int i, float v) {
        return new MyQuery(query.setFloat(i, v));
    }

    public Query setDouble(int i, double v) {
        return new MyQuery(query.setDouble(i, v));
    }

    public Query setBinary(int i, byte[] bytes) {
        return new MyQuery(query.setBinary(i, bytes));
    }

    public Query setText(int i, String s) {
        return new MyQuery(query.setText(i, s));
    }

    public Query setSerializable(int i, Serializable serializable) {
        return new MyQuery(query.setSerializable(i, serializable));
    }

    public Query setDate(int i, Date date) {
        return new MyQuery(query.setDate(i, date));
    }

    public Query setTime(int i, Date date) {
        return new MyQuery(query.setTime(i, date));
    }

    public Query setTimestamp(int i, Date date) {
        return new MyQuery(query.setTimestamp(i, date));
    }

    public Query setEntity(int i, Object o) {
        return new MyQuery(query.setEntity(i, o));
    }

    public Query setLocale(int i, Locale locale) {
        return new MyQuery(query.setLocale(i, locale));
    }

    public Query setCalendar(int i, Calendar calendar) {
        return new MyQuery(query.setCalendar(i, calendar));
    }

    public Query setCalendarDate(int i, Calendar calendar) {
        return new MyQuery(query.setCalendarDate(i, calendar));
    }

    public Query setBinary(String s, byte[] bytes) {
        return new MyQuery(query.setBinary(s, bytes));
    }

    public Query setText(String s, String s1) {
        return new MyQuery(query.setText(s, s1));
    }

    public Query setBoolean(String s, boolean b) {
        return new MyQuery(query.setBoolean(s, b));
    }

    public Query setByte(String s, byte b) {
        return new MyQuery(query.setByte(s, b));
    }

    public Query setCharacter(String s, char c) {
        return new MyQuery(query.setCharacter(s, c));
    }

    public Query setDate(String s, Date date) {
        return new MyQuery(query.setDate(s, date));
    }

    public Query setDouble(String s, double v) {
        return new MyQuery(query.setDouble(s, v));
    }

    public Query setEntity(String s, Object o) {
        return new MyQuery(query.setEntity(s, o));
    }

    public Query setFloat(String s, float v) {
        return new MyQuery(query.setFloat(s, v));
    }

    public Query setInteger(String s, int i) {
        return new MyQuery(query.setInteger(s, i));
    }

    public Query setLocale(String s, Locale locale) {
        return new MyQuery(query.setLocale(s, locale));
    }

    public Query setCalendar(String s, Calendar calendar) {
        return new MyQuery(query.setCalendar(s, calendar));
    }

    public Query setCalendarDate(String s, Calendar calendar) {
        return new MyQuery(query.setCalendarDate(s, calendar));
    }

    public Query setLong(String s, long l) {
        return new MyQuery(query.setLong(s, l));
    }

    public Query setSerializable(String s, Serializable serializable) {
        return new MyQuery(query.setSerializable(s, serializable));
    }

    public Query setShort(String s, short i) {
        return new MyQuery(query.setShort(s, i));
    }

    public Query setString(String s, String s1) {
        return new MyQuery(query.setString(s, s1));
    }

    public Query setTime(String s, Date date) {
        return new MyQuery(query.setTime(s, date));
    }

    public Query setTimestamp(String s, Date date) {
        return new MyQuery(query.setTimestamp(s, date));
    }

    public Query setBigDecimal(int i, BigDecimal bigDecimal) {
        return new MyQuery(query.setBigDecimal(i, bigDecimal));
    }

    public Query setBigDecimal(String s, BigDecimal bigDecimal) {
        return new MyQuery(query.setBigDecimal(s, bigDecimal));
    }

    public Query setBigInteger(int i, BigInteger bigInteger) {
        return new MyQuery(query.setBigInteger(i, bigInteger));
    }

    public Query setBigInteger(String s, BigInteger bigInteger) {
        return new MyQuery(query.setBigInteger(s, bigInteger));
    }

    public Query setParameterList(String s, Collection collection, Type type)
            throws HibernateException {
        return new MyQuery(query.setParameterList(s, collection, type));
    }

    public Query setParameterList(String s, Collection collection)
            throws HibernateException {
        return new MyQuery(query.setParameterList(s, collection));
    }

    public Query setParameterList(String s, Object[] objects, Type type)
            throws HibernateException {
        return new MyQuery(query.setParameterList(s, objects, type));
    }

    public Query setParameterList(String s, Object[] objects)
            throws HibernateException {
        return new MyQuery(query.setParameterList(s, objects));
    }

    public Query setProperties(Map map)
            throws HibernateException {
        return new MyQuery(query.setProperties(map));
    }

    public Query setProperties(Object o)
            throws HibernateException {
        return new MyQuery(query.setProperties(o));
    }

    public Query setParameters(Object[] objects, Type[] types) {
        return new MyQuery(query.setParameters(objects, types));
    }

    public Object uniqueResult()
            throws HibernateException {
        return query.uniqueResult();
    }

    public Iterator iterate()
            throws HibernateException {
        return query.iterate();
    }

    public ScrollableResults scroll()
            throws HibernateException {
        return query.scroll();
    }

    public ScrollableResults scroll(ScrollMode scrollMode)
            throws HibernateException {
        return query.scroll(scrollMode);
    }

    public List list()
            throws HibernateException {
        for (int i = 0; i < 50; i++) {
            try {
                return query.list();
            } catch (Exception e) {

            }
        }

        return query.list();
    }

    public int executeUpdate()
            throws HibernateException {
        return query.executeUpdate();
    }

    public Query setLockMode(String s, LockMode lockMode) {
        return new MyQuery(query.setLockMode(s, lockMode));
    }
}
